
package org.cuatrovientos.hotel.baelish.dani;

import java.util.Enumeration;
import java.util.Hashtable;


/**
 * Class represent Hotel
 * @author daniel_ancin
 *
 */
public class Hotel {
	private Hashtable<String,Room> hotel_Rooms = new Hashtable<String,Room>();
	int numero;
	int contador=0;
	
	
	/**
	 * 
	 */
	public Hotel () {
		hotel_Rooms = new Hashtable<String,Room>();
		init();
	}
	
	/**
	 * hotel
	 * onstructor con numero de Habitacion
	 * @param numero
	 */
	public Hotel (int numero){
		this.numero = numero;
		hotel_Rooms=new Hashtable<String,Room>();
		}
	
	private void init () {
		hotel_Rooms.put("Room1", new Room("Room1","Normal"));
		hotel_Rooms.put("Room2", new Room("Room2","Normal"));
		hotel_Rooms.put("Room3", new Room("Room3","Normal"));
		hotel_Rooms.put("Room4", new Room("Room4","Normal"));
		hotel_Rooms.put("Room5", new Room("Room5","Normal"));
		hotel_Rooms.put("Room6", new Room("Room6","Normal"));
		hotel_Rooms.put("Room7", new Room("Room7","Normal"));
		hotel_Rooms.put("Room8", new Room("Room8","Normal"));
		hotel_Rooms.put("Room9", new Room("Room9","Normal"));
		hotel_Rooms.put("Room10", new Room("Room10","Normal"));
		hotel_Rooms.put("Room11", new Room("Room11","Luxe"));
		hotel_Rooms.put("Room12", new Room("Room12","Luxe"));
		hotel_Rooms.put("Room13", new Room("Room13","Luxe"));
		hotel_Rooms.put("Room14", new Room("Room14","Luxe"));
		hotel_Rooms.put("Room15", new Room("Room15","Luxe"));
		hotel_Rooms.put("Room16", new Room("Room16","Luxe"));
		hotel_Rooms.put("Room17", new Room("Room17","Luxe"));
		hotel_Rooms.put("Room18", new Room("Room18","Luxe"));
		hotel_Rooms.put("Room19", new Room("Room19","Luxe"));
		hotel_Rooms.put("Room20", new Room("Room20","Luxe"));
	}

	/**
	 * Method addGuest
	 * @param name
	 * @param room
	 */
	public void addGuest(String name, String room) {
		Enumeration lista = hotel_Rooms.keys();
						
		Room roomOne = new Room(room,hotel_Rooms.get(room).getRoomtype());
		roomOne.setGuest(name);
		hotel_Rooms.put(room, roomOne);

			

	}
	/**
	 * Method delGuest 
	 * @param name
	 */
	public void delGuest(String name) {
		
		Enumeration lista = hotel_Rooms.keys();
		
		while (lista.hasMoreElements()){
			String clave = (String)lista.nextElement();
			if(hotel_Rooms.get(clave).getGuest().equals(name));
			hotel_Rooms.remove(name);
			break;
		}
		
		
	}
	
	
	/**
	 *Method to search Guest 
	 * @param name
	 * @return
	 */
	public String searchGuest(String name) {
		String result="";
		Enumeration lista = hotel_Rooms.keys();
		while (lista.hasMoreElements()){
			String clave = (String)lista.nextElement();
			if (hotel_Rooms.get(clave).getGuest().equals(name)){
				result = hotel_Rooms.get(clave).toString();
			}
						
		}
		result = "Not Found";
		return result;
	}

	/**
	 * Method showAll
	 * @return
	 */
	public String showAll() {
		
		String result="";
		Enumeration lista = hotel_Rooms.keys();
		while (lista.hasMoreElements()){
			String clave = (String)lista.nextElement();
			result = result + clave.toString();
		}
		return result;
		}

	/**
	 * @return the hotelRooms
	 */
	public Hashtable<String, Room> getHotel_Rooms() {
		return hotel_Rooms;
	}

	/**
	 * @param hotelRooms the hotelRooms to set
	 */
	public void setHotel_Rooms(Hashtable<String, Room> hotel_Rooms) {
		this.hotel_Rooms = hotel_Rooms;
	}
	
	
	}



